package cn.bdqn.asecu.service;

import cn.bdqn.pojo.Message;
import cn.bdqn.repository.Asecu_MessageRepository;
import cn.bdqn.vo.UserMessage;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import javax.annotation.Resource;
import java.util.List;

@Service
public class MessageService {

    @Resource
    Asecu_MessageRepository asecu_messageRepository;


    public List<UserMessage> getMessage(Integer id) {
        List<UserMessage> messageList = asecu_messageRepository.findByHaveId(id);
        return messageList;
    }
@Transactional
    public void delMessage(Integer[] ids) {
        for (Integer id : ids) {
            asecu_messageRepository.deleteById(id);
        }
    }
@Transactional
    public void makeAsRead(Integer[] ids) {
        for (Integer id : ids) {
            asecu_messageRepository.makeAsRead(id);
        }
    }
}